import handle from './index';

let reducer = (state = { ...handle.state }, action: { type: string }) => {

  // 调用dispatch后执行这里的代码
  let newState = JSON.parse(JSON.stringify(state))
  // switch (action.type) {
  //   case handle.sarrpush:
  //     handle.actions[handle.sarrpush](newState, action)
  //     break;;
  //   default:
  //     break;
  // }

  for (let key in handle.actionNames) {
    if (action.type === handle.actionNames[key]) {
      handle.actions[handle.actionNames[key]](newState, action);
      break;
    }
  }

  return newState
}

export default reducer;